***************************************************************************
* Title:    Anger, Fear, and The Racialization of News 
*               Media Coverage of Protest Activity 	 			  	 			          
* Authors: 	LaGina Gause  (lgause@ucsd.edu) 
* 			Steven Moore  (stmoore@wesleyan.edu)
*			Mara Cecilia Ostfeld  (mostfeld@umich.edu)
* Date: 8/1/2023                                                       
* Software: Stata 14.2                                                    
***************************************************************************


// set directory
set more off
set matsize 800




********************************************************************************
*********************************** TABLES *************************************
********************************************************************************


**** Table 1: Text Analyses of Media Depictions of Protesters (Liberal Protests) ****
**** Table 1: Text Analyses of Media Depictions of Protesters (Liberal Protests) ****
**** Table 1: Text Analyses of Media Depictions of Protesters (Liberal Protests) ****

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/


destring *, ignore("NA") replace

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"
label variable cable "Cable"

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

reg fear nonwhite i.media racialissue police word_count year if liberal==1
outreg2 using table1.doc, replace ctitle(Fear Words) label dec(3)

reg anger nonwhite i.media racialissue police word_count year if liberal==1
outreg2 using table1.doc, append ctitle(Anger Words) label dec(3)

reg fear i.nonwhite##i.media racialissue police word_count year if liberal==1
outreg2 using table1.doc, append ctitle(Fear Words) label dec(3)


reg anger i.nonwhite##i.media racialissue police word_count year if liberal==1
outreg2 using table1.doc, append ctitle(Anger Words) label dec(3)


***************************************************************************************
*********************************** APPENDIX TABLES ***********************************
***************************************************************************************


*** Table A2: Fear and Anger in the 20 Words around Mentions of Protesters (Liberal Protests) ***
*** Table A2: Fear and Anger in the 20 Words around Mentions of Protesters (Liberal Protests) ***
*** Table A2: Fear and Anger in the 20 Words around Mentions of Protesters (Liberal Protests) ***

/* 
Required Dataset

jrep_mediabias_replication_data_protestercontext.csv
*/

destring *, ignore("NA") replace

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"

reg fearcountic i.nonwhite i.media racialissue police word_count year if liberal==1
outreg2 using tableA2.doc, replace ctitle(Fear Words) label dec(3)

reg angercountic i.nonwhite  i.media racialissue police  word_count year if liberal==1
outreg2 using tableA2.doc, append ctitle(Anger Words) label dec(3)

reg fearcountic i.nonwhite##i.media racialissue police word_count year if liberal==1
outreg2 using tableA2.doc, append ctitle(Fear Words) label dec(3)

reg angercountic i.nonwhite##i.media racialissue police word_count year if liberal==1
outreg2 using tableA2.doc, append ctitle(Anger Words) label dec(3)




*** Table A3: Fear and Anger in the 20 Words around Mentions of “Protest,” “Rally,” “Riot” (Liberal Protests) ***
*** Table A3: Fear and Anger in the 20 Words around Mentions of “Protest,” “Rally,” “Riot” (Liberal Protests) ***
*** Table A3: Fear and Anger in the 20 Words around Mentions of “Protest,” “Rally,” “Riot” (Liberal Protests) ***

/* 
Required Dataset

jrep_mediabias_replication_data_protestcontext.csv
*/

destring *, ignore("NA") replace

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"

reg fearcountic i.nonwhite i.media racialissue police word_count year if liberal==1
outreg2 using tableA3.doc, replace ctitle(Fear Words) label dec(3)

reg angercountic i.nonwhite  i.media racialissue police  word_count year if liberal==1
outreg2 using tableA3.doc, append ctitle(Anger Words) label dec(3)

reg fearcountic i.nonwhite##i.media racialissue police word_count year if liberal==1
outreg2 using tableA3.doc, append ctitle(Fear Words) label dec(3)

reg angercountic i.nonwhite##i.media racialissue police word_count year if liberal==1
outreg2 using tableA3.doc, append ctitle(Anger Words) label dec(3)


***** Table A4: Media Depictions of Protesters Based on Whether Protest Issue is Police Violence ****
***** Table A4: Media Depictions of Protesters Based on Whether Protest Issue is Police Violence ****
***** Table A4: Media Depictions of Protesters Based on Whether Protest Issue is Police Violence ****

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"
label variable cable "Cable"

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

reg fear i.nonwhite police i.media racialissue  word_count year if liberal==1
outreg2 using tableA4.doc, replace ctitle(Fear Words) label dec(3)

reg anger i.nonwhite police i.media racialissue  word_count year if liberal==1
outreg2 using tableA4.doc, append ctitle(Anger Words) label dec(3)

reg fear i.nonwhite##i.police i.media racialissue  word_count year if liberal==1
outreg2 using tableA4.doc, append ctitle(Fear Words) label dec(3)


reg anger i.nonwhite##i.police i.media racialissue  word_count year if liberal==1
outreg2 using tableA4.doc, append ctitle(Anger Words) label dec(3)





********************************************************************************
*********************************** FIGURES ************************************
********************************************************************************



**** Figure 2: Sentiment from Text Analyses of Media Depictions of Protesters **** 
**** Figure 2: Sentiment from Text Analyses of Media Depictions of Protesters **** 
**** Figure 2: Sentiment from Text Analyses of Media Depictions of Protesters **** 

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace


label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"
label variable cable "Cable"

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

reg fear i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(A): Fear by Race of Protesters", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.001(.001).006) /// 
xtitle ("Race of Protesters") ytitle("Net Fear") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))


reg fear i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, dydx(nonwhite) vsquish atmeans


reg anger i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(B): Anger by Race of Protesters", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.001(.001).006) /// 
xtitle ("Race of Protesters") ytitle("Net Anger") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))




**** Figure 3: Sentiment from Text Analysis of Media Depictions of Protesters By Media Outlet (Liberal Protests) ****
**** Figure 3: Sentiment from Text Analysis of Media Depictions of Protesters By Media Outlet (Liberal Protests) ****
**** Figure 3: Sentiment from Text Analysis of Media Depictions of Protesters By Media Outlet (Liberal Protests) ****

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"
label variable cable "Cable"

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

reg fear i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, dydx(nonwhite) over(media) vsquish atmeans
marginsplot, graphregion(fcolor(white)) recast(bar)  ///
title("(A): Race of Protesters on Fear by Outlet", color(black)) ///
yline(0, lcolor(black))  /// 
xtitle ("Media Outlet") ytitle("Non-White vs White Protesters") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash)) ylabel(-.001(.001).004)


reg anger i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, dydx(nonwhite) over(media) vsquish atmeans
marginsplot, graphregion(fcolor(white)) recast(bar)  ///
title("(B): Race of Protesters on Anger by Outlet", color(black)) ///
yline(0, lcolor(black)) ylabel(-.001(.001).004) /// 
xtitle ("Media Outlet") ytitle("Non-White vs White Protesters") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash)) ylabel(-.001(.001).004)





*** Figure 4(A/B): Fear and Anger in the 20 Words around Mentions of Protesters ***
*** Figure 4(A/B): Fear and Anger in the 20 Words around Mentions of Protesters ***
*** Figure 4(A/B): Fear and Anger in the 20 Words around Mentions of Protesters ***

/* 
Required Dataset

jrep_mediabias_replication_data_protestercontext.csv
*/

destring *, ignore("NA") replace

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"


reg fearcountic i.nonwhite##i.media racialissue year if liberal==1
margins, at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(A): Fear by Race of Protesters " "Around Mentions of “Protester(s)” or “Protestor(s)”", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.2(.2)1.2) /// 
xtitle ("Race of Protesters") ytitle("Net Fear") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))

reg fearcountic i.nonwhite##i.media racialissue year if liberal==1
margins, dydx(nonwhite) vsquish atmeans

reg angercountic i.nonwhite##i.media racialissue year if liberal==1
margins, at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(B): Anger by Race of Protesters " " Around Mentions of “Protester(s)” or “Protestor(s)”", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.2(.2)1.2) /// 
xtitle ("Race of Protesters") ytitle("Net Anger") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))



*** Figure 4(C/D): Fear and Anger in the 20 Words around Mentions of Rally or Riot ***
*** Figure 4(C/D): Fear and Anger in the 20 Words around Mentions of Rally or Riot ***
*** Figure 4(C/D): Fear and Anger in the 20 Words around Mentions of Rally or Riot ***

/* 
Required Dataset

jrep_mediabias_replication_data_protestcontext.csv
*/

destring *, ignore("NA") replace

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"


reg fearcountic i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(C): Fear by Race of Protesters" "Around Mentions of “Protest” “Rally” “Riot”", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.2(.2)1.2) /// 
xtitle ("Race of Protesters") ytitle("Net Fear") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))


reg angercountic i.nonwhite##i.media racialissue police word_count year if liberal==1
margins, at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(D): Anger by Race of Protesters" "Around Mentions of “Protest” “Rally” “Riot”", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.2(.2)1.2) /// 
xtitle ("Race of Protesters") ytitle("Net Anger") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))



*** Figure 5: Sentiment from Text Analysis of Media Depictions of Protesters Based on Whether Protest Grievance is Police Violence *** 
*** Figure 5: Sentiment from Text Analysis of Media Depictions of Protesters Based on Whether Protest Grievance is Police Violence *** 
*** Figure 5: Sentiment from Text Analysis of Media Depictions of Protesters Based on Whether Protest Grievance is Police Violence *** 

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace

label variable racialissue "Racial Issue"
label variable year "Year" 
label variable police "Police Grievance"
label variable word_count "Transcript Word Count"
label variable nonwhite "Non-White"
label variable cable "Cable"

label define outlet 0 "FOX" 1 "CNN" 2 "ABC" 3 "CBS" 4 "NBC" 5 "MSBNC" , modify
label values media outlet

reg fear i.nonwhite##i.police media racialissue  word_count year if liberal==1
margins, dydx(police)  at(nonwhite=(0 1)) vsquish atmeans
marginsplot, recast(bar) xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(A): Police Grievance on Fear by Protester's Race", color(black)) ///
yline(0, lcolor(black))  /// 
xtitle ("Race of Protesters") ytitle("Difference in Effect of Police Grievance") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash)) ylabel(-.006(.002).004)


reg fear i.nonwhite##i.police media racialissue  word_count year if liberal==1
margins, dydx(nonwhite)  vsquish atmeans

reg anger i.nonwhite##i.police media racialissue  word_count year if liberal==1
margins, dydx(police)  at(nonwhite=(0 1)) vsquish atmeans
marginsplot, recast(bar) xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(B): Police Grievance on Anger by Protester's Race", color(black)) ///
yline(0, lcolor(black))  /// 
xtitle ("Race of Protesters") ytitle("Difference in Effect of Police Grievance") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash)) ylabel(-.006(.002).004)

reg anger i.nonwhite##i.police media racialissue  word_count year if liberal==1
margins, dydx(nonwhite)  vsquish atmeans


****************************************************************************************
*********************************** APPENDIX FIGURES ***********************************
****************************************************************************************

**** Figure A1: Sentiment from Text Analyses of Cable vs Broadcast Depictions of Protesters **** 
**** Figure A1: Sentiment from Text Analyses of Cable vs Broadcast Depictions of Protesters **** 
**** Figure A1: Sentiment from Text Analyses of Cable vs Broadcast Depictions of Protesters **** 

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace

reg fear i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(cable)  vsquish atmeans
marginsplot,  graphregion(fcolor(white)) ///
title("(A): Fear by Outlet Type", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.001(.001).006) /// 
ytitle ("Cable (vs Broadcast)") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))

reg anger i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(cable)  vsquish atmeans
marginsplot,  graphregion(fcolor(white)) ///
title("(B): Anger by Outlet Type", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.001(.001).006) /// 
ytitle ("Cable (vs Broadcast)") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))

**** Figure A2: Sentiment from Text Analyses of Cable vs Broadcast Depictions by Protesters' Race **** 
**** Figure A2: Sentiment from Text Analyses of Cable vs Broadcast Depictions by Protesters' Race **** 
**** Figure A2: Sentiment from Text Analyses of Cable vs Broadcast Depictions by Protesters' Race **** 

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace

reg fear i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(cable) at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(A): Fear by Race of Protesters", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.001(.001).006) /// 
xtitle ("Race of Protesters") ytitle("Cable (vs Broadcast)") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))


reg anger i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(cable) at(nonwhite=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Nonwhite" 0 "White") graphregion(fcolor(white))  ///
title("(B): Anger by Race of Protesters", color(black)) recast(bar) ///
yline(0, lcolor(black) lpattern(dash)) ylabel(-.001(.001).006) /// 
xtitle ("Race of Protesters") ytitle("Cable (vs Broadcast)") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash))


reg anger i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(nonwhite) vsquish atmeans


**** Figure A3: Sentiment from Text Analysis of Cable vs Broadcast Depictions of Protesters By Media Outlet (Liberal Protests) ****
**** Figure A3: Sentiment from Text Analysis of Cable vs Broadcast Depictions of Protesters By Media Outlet (Liberal Protests) ****
**** Figure A3: Sentiment from Text Analysis of Cable vs Broadcast Depictions of Protesters By Media Outlet (Liberal Protests) ****

/* 
Required Dataset

jrep_mediabias_replication_data.csv
*/

destring *, ignore("NA") replace

reg fear i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(nonwhite) at(cable=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Cable" 0 "Broadcast") graphregion(fcolor(white)) recast(bar)  ///
title("(A): Race of Protesters on Fear by Outlet", color(black)) ///
yline(0, lcolor(black))  /// 
xtitle ("Media Outlet") ytitle("Non-White vs White Protesters") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash)) ylabel(-.002(.002).006)


reg fear i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(cable) vsquish atmeans



reg anger i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(nonwhite) at(cable=(0 1)) vsquish atmeans
marginsplot, xlabel(1 "Cable" 0 "Broadcast") graphregion(fcolor(white)) recast(bar)  ///
title("(B): Race of Protesters on Anger by Outlet", color(black)) ///
yline(0, lcolor(black))  /// 
xtitle ("Media Outlet") ytitle("Non-White vs White Protesters") ///
plotopts(color(gs12) msize(small) lcolor(black) ) ciopts(lcolor(black) lpattern(dash)) ylabel(-.002(.002).006)


reg anger i.nonwhite##i.cable racialissue police word_count year if liberal==1
margins, dydx(cable) vsquish atmeans








